﻿<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converter="clr-namespace:Pronama.Sekatyaku.Converter"
    Title="異世界の新着動画" Width="640" Height="480"
        AllowDrop="True"
        >
    <Window.Resources>
        <converter:TimeSpanToStringConverter x:Key="TimeSpanToStringConverter"/>

        <Style TargetType="{x:Type ListViewItem}">
            <Style.Triggers>
                <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                    <Setter Property="Background" Value="#F3F7FB"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <ToolBarPanel>
            <ToolBarTray>
                <ToolBar>
                    <TextBox Name="LiveIdTextBox" Width="200" VerticalAlignment="Center" />
                    <Image Source="Images/cookie.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                    <ComboBox Name="CookieComboBox" Width="150" />
                    
                    <!--<Menu Background="Transparent" Width="{Binding ElementName=ConnectButton, Path=ActualWidth}"
                          Padding="0">
                        <MenuItem Padding="2" ToolTip="Cookie の選択">
                            <MenuItem.Header>
                                <Image Source="Images/cookie.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                            </MenuItem.Header>
                            <MenuItem Header="Internet Explorer" IsCheckable="True" x:Name="IEMenuItem" Click="IEMenuItem_Click" />
                            <MenuItem Header="Firefox" IsCheckable="True" x:Name="FirefoxMenuItem" Click="FirefoxMenuItem_Click" />
                            <MenuItem Header="Google Chrome" IsCheckable="True" x:Name="GoogleChromeMenuItem" Click="GoogleChromeMenuItem_Click" />
                            <MenuItem Header="Opera" IsCheckable="True" x:Name="OperaMenuItem" Click="OperaMenuItem_Click" />
                        </MenuItem>
                    </Menu>-->
                    <Button ToolTip="開始" x:Name="ConnectButton" Click="Button_Click">
                        <Image Source="Images/lightning.png" Width="16" Height="16" SnapsToDevicePixels="True" Name="Image1" />
                    </Button>
                    <Button ToolTip="終了" x:Name="DisconnectButton" Click="DisconnectButton_Click">
                        <Image Source="Images/lightning_cross.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                    </Button>

                </ToolBar>
            </ToolBarTray>
        </ToolBarPanel>
        <ToolBarPanel Grid.Column="1">
            <ToolBarTray>
                <ToolBar HorizontalAlignment="Right">
                    <Menu Background="Transparent" Width="{Binding ElementName=ConnectButton, Path=ActualWidth}"
                          Padding="0">
                        <MenuItem Padding="2" ToolTip="設定">
                            <MenuItem.Header>
                                <Image Source="Images/gear.png" Width="16" Height="16" SnapsToDevicePixels="True" />
                            </MenuItem.Header>
                            <MenuItem Header="設定..." Click="MenuItem_Click" />
                            <Separator />
                            <MenuItem Header="ダウンロード サイト" Click="DownloadSiteMenuItem_Click" />
                            <MenuItem Header="サポート" Click="SupportMenuItem_Click" />
                        </MenuItem>
                    </Menu>

                </ToolBar>
            </ToolBarTray>
        </ToolBarPanel>
        <ListView Name="VideosListView"                   
                  AlternationCount="2"
                  ItemsSource="{Binding Videos}"
                  Grid.Row="1" Grid.ColumnSpan="2"
                  Margin="10">
            <ListView.View>
                <GridView AllowsColumnReorder="False">
                    <GridViewColumn Width="100">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Image Source="{Binding ThumbnailUri}"
                                       Width="96" Height="72" />
                                    <Grid HorizontalAlignment="Left" VerticalAlignment="Top"
                                          Background="Black" Opacity="0.5"
                                          Width="{Binding ElementName=IdTextBlock, Path=ActualWidth}"
                                          Height="{Binding ElementName=IdTextBlock, Path=ActualHeight}"/>
                                    <TextBlock x:Name="IdTextBlock" 
                                               HorizontalAlignment="Left" VerticalAlignment="Top"
                                               Text="{Binding Path=Id}" 
                                               Padding="2 0 2 0"
                                               Foreground="White" FontWeight="Bold" />
                                    
                                    <Grid HorizontalAlignment="Right" VerticalAlignment="Bottom"
                                          Background="Black" Opacity="0.5"
                                          Width="{Binding ElementName=LengthTextBlock, Path=ActualWidth}"
                                          Height="{Binding ElementName=LengthTextBlock, Path=ActualHeight}"/>
                                    <TextBlock x:Name="LengthTextBlock" 
                                               HorizontalAlignment="Right" VerticalAlignment="Bottom"
                                               Text="{Binding Path=Length, Converter={StaticResource TimeSpanToStringConverter}}" 
                                               Padding="2 0 2 0"
                                               Foreground="White" FontWeight="Bold" />
                                </Grid>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel VerticalAlignment="Center">
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                        <TextBlock Text="{Binding FirstRetrieveDateTime}" VerticalAlignment="Center"
                                                   FontWeight="Bold" />
                                        <TextBlock Text="投稿" VerticalAlignment="Center" Margin="3 0 0 0" />
                                    </StackPanel> 
                                    <TextBlock Text="{Binding Title}" FontWeight="Bold" />
                                    <TextBlock Text="{Binding ShortDescription}" />
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        
        <Grid Grid.Row="1" Grid.ColumnSpan="2"
              Name="DescriptionGrid">
            <!--<Image Source="Images/description.png" Width="450" Height="290"
                   SnapsToDevicePixels="True" Opacity="0.9" />-->
            <Grid Background="Black" Opacity="0.5" 
                  HorizontalAlignment="Center" VerticalAlignment="Center"
                  Width="{Binding ElementName=InnerDescriptionGrid, Path=ActualWidth}"
                  Height="{Binding ElementName=InnerDescriptionGrid, Path=ActualHeight}"/>
            <Grid x:Name="InnerDescriptionGrid"
                  Background="Transparent"
                  Width="Auto" Height="Auto"
                  HorizontalAlignment="Center" VerticalAlignment="Center">
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
                       Foreground="White"
                       Padding="3">
                ここに Web ブラウザから動画を選択してドラッグ＆ドロップします。<LineBreak />
                または、HTML やテキストをコピー＆ペースト(Ctrl + V)します。<LineBreak />
                    <Hyperlink Click="Hyperlink_Click">異世界の新着動画の使い方(sm9893018)</Hyperlink>
                </TextBlock>
                
            </Grid>
        </Grid>
    
        
        <StatusBar Grid.Row="2" Grid.ColumnSpan="2">
            <StatusBarItem DockPanel.Dock="Right">
                <TextBlock x:Name="RightSideStatusBarTextBox" Margin="0 0 5 0" />
            </StatusBarItem>
            
            <StatusBarItem>
                <TextBlock Name="StatusBarTextBlock" Margin="5 0 0 0">
                    <TextBlock.Resources>
                        <Storyboard x:Key="FadeStoryboard">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="StatusBarTextBlock" Storyboard.TargetProperty="Opacity">
                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:05" Value="1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:06" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </TextBlock.Resources>
                </TextBlock>
            </StatusBarItem>
 
        </StatusBar>
    </Grid>
</Window>
